/**
 * 
 */
package org.gigi.security.web;

import java.util.List;

import org.gigi.core.web.ListResponse;
import org.gigi.security.domain.Authority;
import org.gigi.security.service.AuthorityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * AuthorityController
 *
 * @author Eugene Wang 2011-10-14
 * @see
 */
@Controller
@RequestMapping("/sec/authority")
public class AuthorityController {
	/*Logger*/
	private static final Logger LOGGER = LoggerFactory.getLogger(AuthorityController.class);
	private static final boolean LOG_DEBUG = LOGGER.isDebugEnabled();
	@Autowired
	private AuthorityService authorityService;

	/**
	 * 获取所有权限。
	 * @return
	 */
	@RequestMapping(method=RequestMethod.GET)
	public @ResponseBody ListResponse<Authority> findAll() {
		if (LOG_DEBUG) {
			LOGGER.debug("获取所有权限列表");
		}
		List<Authority> authorities = authorityService.findAll();
		ListResponse<Authority> response = new ListResponse<Authority>("成功获取所有权限", authorities);
		return response;
	}
}
